package com.idheima.zuoye.zuoye4;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Test {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("王佳乐");
        list.add("张三丰");
        list.add("张飞");
        list.add("王思聪");
        list.add("刘晓敏");
        list.add("王敏");
        for (String s : list) {
            System.out.println(s);
        }
        System.out.println("----------");
        List<String> wang = list.stream()
                .filter(s -> s.startsWith("王"))
                .collect(Collectors.toList());
        List<String> zhang = list.stream()
                .filter(s -> s.startsWith("张"))
                .collect(Collectors.toList());
        long count = Stream.concat(wang.stream(), zhang.stream()).filter(s -> s.length() == 3).count();
        System.out.println("名字性张和王并且名字长度为3个字的人共有："+count+"个");

    }
}
